﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<WebMassage.Models.New>" %>

<%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Chỉnh sửa tin tức
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script src="<%= Url.Content("~/Scripts/jquery-1.4.1.js") %>" type="text/javascript"></script>
    <script type="text/javascript" src="<%= Url.Content("~/Scripts/jquery.validate.js") %>"> </script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#aspnetForm").validate({
                rules: {
                    Title: "required",
                    <%= Content.ClientID %>: "required"
                },
                messages: {
                    Title: " Chưa có dữ liệu",
                    <%= Content.ClientID %>: " Bạn chưa nhập nội dung cho tin tức mới"
                }
            });
        });
    </script>
    <script runat="server">
        protected void Page_Load(object sendder, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                Content.Text = Model.Content;
            }
        }
    </script>
    <div style="padding: 10px;">
        <h2>
            Chỉnh sửa tin tức</h2>
            <br />
            
        <form id="aspnet" runat="server">
        <% using (Html.BeginForm())
           {%>
        <%= Html.ValidationSummary(true) %>
          <fieldset style="padding: 10px;">
            <div class="editor-label">
                Tiêu đề:  <%= Html.TextBoxFor(model => model.Title, new { style = "width:70%" })%>
            </div>
            <div class="editor-label">
                Nội dung
            </div>
            <div class="editor-field">
                <CKEditor:CKEditorControl ID="Content" runat="server" ClientIDMode="Inherit">
                </CKEditor:CKEditorControl>
            </div>
            <div class="editor-label">
                Ngày tạo:
                <%= string.Format("{0:dd/MM/yyyy}",DateTime.Now) %>
            </div>
            <div class="editor-label">
                Người tạo:
                <% = Page.User.Identity.Name%>
            </div>
            <p>
                <input type="submit" value="Lưu" />
            </p>
        </fieldset>
        <% } %>
        </form>
        <div style="padding-top:20px">
               <%= Html.ActionLink("Trở về danh sách", "Manager") %>
        </div>
    </div>
</asp:Content>
